package entities;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;

import util.Vector2D;

public class AimingShot extends Shot {
	
	private Entity target;
	private float aimingStrength;
	private float maxSpeed;
	private float friction;
	
	public AimingShot(String image, Entity owner, int damage, Vector2D velocity, Entity target) throws SlickException {
		super(image, owner, damage, velocity);
		this.target = target;
		aimingStrength = 200f;
		maxSpeed = 500.0f;
		friction = 2.0f;
	}
	
	public void setAimingStrength(float strength) {
		this.aimingStrength = strength;
	}
	
	public void setMaxSpeed(float speed){
		this.maxSpeed = speed;
	}
	
	public void setFriciton(float friction) {
		this.friction = friction;
	}

	public void update(GameContainer gc, int delta) {		
		super.update(gc, delta);
		Vector2D targetPos = target.pos;
		acceleration = (targetPos.subtract(pos)).getUnitVector().scale(aimingStrength);
		if (velocity.getLength() > maxSpeed) {
			velocity = velocity.getUnitVector().scale(maxSpeed);
		}
		velocity = velocity.scale(1.0f - (friction * (delta / 1000.0f)));
	}
	
	
}
